﻿@model List<Sahit.iSoilHotel.Portal.ServiceProxy.Tavern.Models.Room.RoomViewModel>
@{
    ViewBag.Title = "Index";
}
<script type="text/javascript">
    var selectedRoom;
    var selectedRoomStatus;
    function reserve() {
        if (selectedRoom == undefined)
            return;
        if (selectedRoomStatus != "0") {
            alert("This room is not empty!");
            return;
         }
        var reserveURL = "Record/Reserve?";
        reserveURL += ("RoomID=" + selectedRoom);
        window.navigate(reserveURL);
    }

    function checkin() {
        if (selectedRoom == undefined)
            return;
        if (selectedRoomStatus != "0" && selectedRoomStatus!="1" ) {
            alert("This room is not empty or reserved!");
            return;
        }
        var reserveURL = "Record/CheckIn?";
        reserveURL += ("RoomID=" + selectedRoom);
        window.navigate(reserveURL);
    }

    function checkout() {
        if (selectedRoom == undefined)
            return;
        if (selectedRoomStatus != "2") {
            alert("This room is not checked in!");
            return;
        }
        var reserveURL = "Record/CheckOut?";
        reserveURL += ("RoomID=" + selectedRoom);
        window.navigate(reserveURL);
    }
</script>
 @{Html.RenderPartial("RoomView", Model);}
<div style="clear:both"></div>
<input type="button" value="Reserve" onclick="reserve()" />
<input type="button" value="Check In" onclick="checkin()" />
<input type="button" value="Check Out" onclick="checkout()" />

